package exception;

public class FinallyDemo2 {
    public static void main(String[] args) {
        System.out.println(test("0")+","+test(null)+","+test(""));//如果没有finally，则输出0，1，2   如果有finally，则输出3，3，3 因为只要执行try，最后都会执行finally

    }
    public static int test(String s) {

        try {
            return s.charAt(0)-'0';
        } catch (NullPointerException e) {
            return 1;
        } catch (Exception e) {
            return 2;
        } finally {
            return 3;
        }
    }
}

